<template>
  <el-dialog :visible.sync="detailsVisible" width="600px" @click="hideDetail" :show-close='false'>
    <div slot="title" class="dialog-title">用户详情</div>
    <el-row>
      <el-col :span="4" class="info">用户名：</el-col>
      <el-col :span="20" class="info">
        {{getUserName(details)}}
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="4" class="info">账号：</el-col>
      <el-col :span="20" class="info">{{details.mobile}}</el-col>
    </el-row>
    <el-row>
      <el-col :span="4" class="info">用户类型：</el-col>
      <el-col :span="20" class="info">{{details.user_type==1?'个人':details.user_type==2?'企业':'个人/企业'}}</el-col>
    </el-row>
    <el-row>
      <el-col :span="4" class="info">来源：</el-col>
      <el-col :span="20" class="info">{{getSourceText(details.source)}}</el-col>
    </el-row>
    <el-row v-if="details.user_type==2&&details.profession_company&&details.profession_company.length>0">
      <el-col :span="4" class="info">其他企业：</el-col>
      <el-col :span="20" class="info">
        <p :key='item.id' v-for="item in details.profession_company">{{item.name}}</p>
      </el-col>
    </el-row>
    <el-row v-if="details.user_type==3">
      <el-col :span="4" class="info">姓名：</el-col>
      <el-col :span="20" class="info">{{details.nick_name}}</el-col>
    </el-row>
    <el-row v-if="details.user_type==3&&details.profession_select_company">
      <el-col :span="4" class="info">企业名称：</el-col>
      <el-col :span="20" class="info">{{details.profession_select_company.name}}</el-col>
    </el-row>
    <el-row>
      <el-col :span="4" class="info">备注：</el-col>
      <el-col :span="20" class="info">{{details.note}}</el-col>
    </el-row>
  </el-dialog>
</template>

<script>
import formOperate from '@/layout/mixin/formOperate'
export default {
  name: 'Index',
  mixins: [formOperate],
  data() {
    return {
      details:'',//详情数据
      detailsVisible:false
    }
  },
  methods: {
    show(id) {
      console.log()
      this.$http.get('/user/admin/user/'+id).then(response => {
        if (response.code === 10000) {
          this.details = response.data
        } else {
          this.$message.error(response.message)
        }
      })
      this.detailsVisible  = true
    },
    // 隐藏简历详情dialog
    hideDetail() {
      this.detailsVisible = false
    },
    // 获取用户名
    getUserName(item){
      if (item.source==5) {
        return  item.nick_name || item.username || item.mobile
      } else {
        if (item.chang_type==1) {
          return item.resume_count>0?item.profession_user.full_name:item.nick_name?item.nick_name:item.mobile
        } else if(item.chang_type==2){
          return item.profession_select_company?item.profession_select_company.name:item.username
        } else {
          item.username || item.mobile
        }
      }
    },
  }
}
</script>
<style scoped>
  .info{
    line-height: 36px;
  }
</style>
